package monitor

import (
	"fmt"
	"github.com/gorilla/mux"
	httperror "github.com/portainer/libhttp/error"
	portainer "github.com/portainer/portainer/api"
	"github.com/portainer/portainer/api/http/security"
	"net/http"
)

// Handler is the HTTP handler used to handle authentication operations.
type Handler struct {
	*mux.Router
	DataStore                   portainer.DataStore
	requestBouncer 				*security.RequestBouncer
}

// NewHandler creates a handler to manage authentication operations.
func NewHandler(bouncer *security.RequestBouncer) *Handler {
	h := &Handler{
		Router: mux.NewRouter(),
		requestBouncer: bouncer,
	}

	fmt.Println("monitor NewHandler")

	h.Handle("/monitor/cpu",
		bouncer.PublicAccess(httperror.LoggerHandler(h.monitorCPU))).Methods(http.MethodPost)
	h.Handle("/monitor/mem",
		bouncer.PublicAccess(httperror.LoggerHandler(h.monitorMEM))).Methods(http.MethodPost)
	h.Handle("/monitor/disk",
		bouncer.PublicAccess(httperror.LoggerHandler(h.monitorDisk))).Methods(http.MethodPost)
	//h.Handle("/auth",
	//	rateLimiter.LimitAccess(bouncer.PublicAccess(httperror.LoggerHandler(h.authenticate)))).Methods(http.MethodPost)
	//h.Handle("/auth/logout",
	//	bouncer.AuthenticatedAccess(httperror.LoggerHandler(h.logout))).Methods(http.MethodPost)

	return h
}
